
<!DOCTYPE html>
<html>

<head>
   
    
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--360浏览器优先以webkit内核解析-->


<title>万用申请单</title>

<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
<link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
<!-- Sweet Alert -->
<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
 <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">

 <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">

    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
         <link rel="stylesheet" href="__STATIC__/layout/css/channel.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <style>

        .note-editable {
            height: 150px
        }

    </style>

</head>

<body class="white-bg" style="padding: 3px;font-size: 13px">
    <div class="page-heade">
       <h2 class="title_color text-center">添加万用申请单</h2>
    </div>
   <form  class="form-inline" id="form1">
      <input type="hidden" name="state" id="state"/>
      <input type="hidden" name="aid" value="{$aid}"/>
        <table class="table table-bordered bud_hei text-center">
            <tr>
                <td style="width: 140px;">申请人</td>
                <td class="text-left">{$user.em_name}</td>
                <td style="width: 140px;">申请人部门</td>
                <td class="text-left">{$user.de_name}</td>
            </tr>
            <tr>
                <td>申请时间</td>
                <td class="text-left" >{$ctime}</td>
                <td>申请类型 <span class="colorRed">*</span></td>
                <td class="text-left">
                    <select class="form-control select" name="types">
                        <option value="0">请选择</option>
                        {volist name="wtype" id="wt"}

                        <option value="{$wt.id}" {if $aid}{if $apply.type==$wt.id} selected {/if}{/if}>{$wt.title}</option>
                        {/volist}
                    </select>
                </td>
            </tr>
            <tr>
                <td>主题 <span class="colorRed">*</span></td>
                <td class="text-left" colspan="3"><input type="text" name="title" value="{if $aid}{$apply.title}{/if}" class="form-control" style="width: 50%"></td>
            </tr>
            <tr>
                <td>模板选择</td>
                <td class="text-left" colspan="3"> 
               
                    <select id="moban" class="form-control select">

                        <option value="0">请选择</option>
                      
                            {volist name="wmoban" id="wt"}
                                
                                   <option value="{$wt.id}">{$wt.title}</option>
                               
                            {/volist}
                      
                    </select>
                
                </td>
            </tr>
            <tr>
                <td>申请内容<span class="colorRed">*</span></td>
                <td colspan="3" class="text-left">
                     <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <textarea class="summernote" id="neirong" name="neirong">{if $aid}{$apply.neirong}{/if}</textarea>

                        </div>
                    </div>
                </td>
            </tr>
            <tr>
             <td colspan="4" class="text-left">温馨提醒：本编辑器不支持复杂表单提交，复杂表单请以附件形式提交</td>
            </tr>
            <tr>
                <td>是否涉及费用</td>
                <td colspan="3" class="text-left">
                        <label class="radio-inline" for="no_andCost">
                        <input type="radio" name="iscost" value='0' checked class="form-control" id="no_andCost" onclick="hascosthide()">否
                    </label>
                       <label class="radio-inline" for="is_andCost">
                        <input type="radio"  name="iscost" value='1' {if $aid}{if $apply.iscost==1} checked {/if}{/if} onclick="hascostshow()" class="form-control" id="is_andCost">是
                    </label>
                     
                </td>
            </tr>
            <tr class='hascost' {if $aid}{if $apply.iscost==1}  {else} style='display: none;'{/if} {else} style='display: none;'{/if}>
                <td style="width: 140px;">部门<span class="colorRed">*</span></td>
                <td class="text-left">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-8">
                                <div class="input-group"  style="display:none;" >
                                    <input type="text" placeholder="请输入关键字或空格查询" class="form-control bmid" name="bmid"  value="{$bmid}" >
                                    <div class="input-group-btn">
                                        <button type="button" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                        </ul>
                                    </div>
                                </div>
                                <div class="selectedOnlyOne "  >
                                    <span class="inin">{$bm}</span>
                                    <span class="close">×</span>
                                </div>
                            </div>
                            <div class="col-xs-4">
                                <button class="btn btn-primary select_bmid" type="button" >选择</button>
                            </div>
                        </div>
                    </div>
                    
                    
                        
                </td>
                <td style="width: 140px;">考核期<span class="colorRed">*</span></td>
                <td class="text-left">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-8">
                                <div class="input-group"  style="display:none;" >
                                    <input type="text" placeholder="请输入关键字或空格查询" class="form-control kaoheid" name="kaoheid"  value="{$kaoheid}" >
                                    <div class="input-group-btn">
                                        <button type="button" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                        </ul>
                                    </div>
                                </div>
                                <div class="selectedOnlyOne "  >
                                    <span class="inin">{$kaohe}</span>
                                    <span class="close">×</span>
                                </div>
                            </div>
                            <div class="col-xs-4">
                                <button class="btn btn-primary select_kaoheid" type="button" >选择</button>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr class='hascost' {if $aid}{if $apply.iscost==1} {else} style='display: none;'{/if} {else} style='display: none;'{/if}>
                <td style="width: 140px;">支付方式<span class="colorRed">*</span></td>
                <td class="text-left">
                    <select class="form-control select" id="zhifu" name="zhifu">
                        <option value="0">请选择</option>
                        {if $aid}
                            {volist name="pay" id="p"}
                                {if $p.id==$apply.zhifu}
                                <option value="{$p.id}" selected>{$p.title}</option>
                                {else/}
                                <option value="{$p.id}">{$p.title}</option>
                                {/if}
                            {/volist}
                        {else/}
                            {volist name="pay" id="p"}
                                <option value="{$p.id}">{$p.title}</option>
                            {/volist}
                        {/if}
                    </select>
                </td>
                <td style="width: 140px;">收款人<span class="colorRed">*</span></td>
                <td class="text-left">
                    <div class="container-fluid">
                            <div class="row">
                                <div class="col-xs-8">
                                    <div class="input-group"  style="display:none;"  >
                                        <input type="text" placeholder="请输入关键字或空格查询" class="shoukuan form-control"  name="shoukuan" value="{$shoukuanid}">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="selectedOnlyOne " >
                                      
                                        <span class="inin">{$shoukuan}</span>
                                        <span class="close">×</span>
                                    </div>
                                </div>
                               <div class="col-xs-4">
                                <button class="btn btn-primary select_shoukuan" type="button" >选择</button>
                            </div>
                           </div>
                        </div>
                </td>
            </tr>

        </table>
        <table class="hascost table table-bordered bud_hei text-center" {if $aid}{if $apply.iscost==1} {else} style='display: none;'{/if} {else} style='display: none;'{/if}>
            <thead><tr>
                <th>费用科目</th>
                <th>金额</th>
                <th>费用说明</th>
                <th><button type="button" class='btn btn-primary addline'>添加</button></th>
            </tr></thead>
            <tbody id="line">
            {volist name="detail" id='vo'}
            <tr>
                <td><select name='feetype[]'>
                    <option value='0'>--请选择--</option>
                    {volist name="fei3" id="f"}
                    <option value="{$f.id}" {if $f.id==$vo.feetype} selected {/if}>{$f.title}</option>
                    {/volist}
                </select></td>
                <td><input type='text' class='form-control numi' value='{$vo.fee}' name='fee[]'/></td>
                <td><input type="text" class='form-control' value="{$vo.remark}" name="remark[]"/></td>
                <td><button type="button" class='btn btn-danger scline'>删除</button></td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-sm btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach"  {if $aid}{if $apply.fujian} value="{$apply.fujian}" {/if}{/if}  >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>

        <div class="padding-10 text-center">
          <button class="btn btn-primary" type="button" onclick="baocun(1)">保存为草稿</button><span class="lr_5"></span>
          <button class="btn btn-success" type="button" onclick="baocun(3)">保存并提交工作流</button><span class="lr_5"></span>
          <button class="btn btn-warning" type="button" id="fanhui">返回</button></div>
    </form>
  
    
<!-- 全局js -->
<script src="__STATIC__/layout/js/jquery.min.js"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Sweet alert -->
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>

<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
$(".addline").click(function(){
    var str="<tr><td><select name='feetype[]'><option value='0'>--请选择--</option>";
    {volist name="fei3" id="f"}
             str+="<option value='"+{$f.id}+"'>"+"{$f.title}"+"</option>" ;    
     {/volist}               
    str+="</select></td><td><input type='text' class='form-control numi' value='' name='fee[]'/></td> <td><input type='text' class='form-control'  name='remark[]'/></td> <td><button type='button' class='btn btn-danger scline'>删除</button></td></tr>" ;        
    $("#line").append(str)

})
$('body').on('click','.scline',function () {
    $(this).parent().parent().remove();
})
//弹出选择我的支付人树
        $('body').on('click','.select_shoukuan',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'支付人树',
                    maxmin:true,
                    content:'{:url("Apcaiwu/selectCname")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.feetype').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
    //支付人搜索自动补全
    $(".shoukuan").bsSuggest({
        url: "{:url('Apcaiwu/cnamejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
 //取消单选
    $('body').on('click','.selectedOnlyOne .close',function () {
        $(this).closest('.selectedOnlyOne').hide().find('.inin').html('')
        $(this).closest('.selectedOnlyOne').prev('.input-group').show().find('input').val('')
        
    })
    //考核期搜索自动补全
    $(".kaoheid").bsSuggest({
        url: "{:url('select/kaoheqijson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
      //弹出选择考核期树
        $('body').on('click','.select_kaoheid',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'考核期树',
                    maxmin:true,
                    content:'{:url("selectKaoheqi")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.kaoheid').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                            
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
  //费用计入部门搜索自动补全
    $(".bmid").bsSuggest({
        url: "{:url('select/bmjson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
    //弹出选择我的费用计入部门树
        $('body').on('click','.select_bmid',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'费用计入部门树',
                    maxmin:true,
                    content:'{:url("Richangbaoxiao/selectJrbm")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.bmid').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                            
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
        function hascostshow(){
            $(".hascost").show();
        }
        function hascosthide(){
            $(".hascost").hide();
        }
    $("#moban").change(function(){
        if($(this).val()>0){
            $.post("{:url('getmoban')}",{mid:$(this).val()},function(re){
                $("#neirong").code(re);
            })
        }
    })
    $(function () {
        $('body').on('click','input[type=text]',function () {
            this.select()
        })
        
    })
</script>
   <script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>

<script>
   
function baocun(state){
  $("#state").val(state);
  $("#neirong").val($("#neirong").code());
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('addchuli')}",
          data:$('#form1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  parent.location.href="{:url('mywanyong')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }          
          }
        });
}   
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });

          $('#fanhui').on('click',function () {
//                    parent.layer.close(parent.layer.getFrameIndex(window.name))
                    parent.location.reload();
                    return false
                })
    });

  
 $('#reset').on('click',function () {
            $("#form1 input").each(function(){
                $(this).val('');
            });
            $("#form1 select").each(function(){
                $(this).val('');
            });
            $('#form1').submit()
            return false
        })
</script>

<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if $aid}{if $apply.fujian}value="{$apply.fujian}"{/if}{/if} ];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

        $('#renyuan').on('click','.ren .close',function () {
            $(this).closest('.ren').remove()
        })
    });
   

</script>
</body>

</html>